package com.zking.controller.jch;

import com.zking.entity.Seller;
import com.zking.service.jch.BusinessAuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/BusinessAudit")
public class BusinessAuditController {
    @Autowired
    private BusinessAuditService businessAuditService;


    @RequestMapping(value = "/selectBusinessAll")
        public String queryBusinessAuditAll(HttpServletRequest request) {
        List<Seller> sellers = businessAuditService.queryBusinessAuditAll();
        request.setAttribute("sellers",sellers);
        return "jch/seller_1";
        }

        @RequestMapping("/selectBusinessByName")
        @ResponseBody
       public  Seller queryBusinessAuditByName(String name){
             Seller seller = businessAuditService.queryBusinessAuditByName(name);
//             request.setAttribute("seller",seller);
             return seller;
        }

        //审核通过
        @RequestMapping(value = "/changeStatusTrue")
        @ResponseBody
        public void changeStatusTrue(String sellerId){
            boolean b = businessAuditService.updateStatusTrue(sellerId);
            System.out.println(b);
        }

        //审核不通过
        @RequestMapping(value = "/changeStatusFalse")
        @ResponseBody
        public void changeStatusFalse(String sellerId){
            boolean b = businessAuditService.updateStatusFalse(sellerId);
            System.out.println(b);
        }



        @RequestMapping(value = "/selectBusinessStatusAll")
        public String selectBusinessStatusAll(HttpServletRequest request) {
            List<Seller> sellers = businessAuditService.queryBusinessAuditAll();
            request.setAttribute("sellers",sellers);
            return "jch/seller";
        }
}
